package com.salefinder.client;

import java.util.List;

import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.salefinder.client.vo._ConsumerProductVO;

public class SearchResultsScreen extends LayoutContainer{
	
	private List<_ConsumerProductVO> resultList;
	
	@Override
	protected void onRender(Element parent, int index) { 
		super.onRender(parent, index);
		this.setLayout(new FitLayout());
		
		_ConsumerProductVO prod = new _ConsumerProductVO();
		prod.setName("some");
		
		SaleFinderServiceAsync saleFinderSvc = GWT.create(SaleFinderService.class);

		// Set up the callback object.
	    AsyncCallback<List<_ConsumerProductVO>> callback = new AsyncCallback<List<_ConsumerProductVO>>() {
	      public void onFailure(Throwable caught) {
	        // TODO: Do something with errors.
	      }
		@Override
		public void onSuccess(List<_ConsumerProductVO> result) {
			resultList = result;
			
		}
	    };
	    
	    saleFinderSvc.searchProduct(prod, callback);
		
		TableLayout layout = new TableLayout();
		layout.setCellSpacing(10);
		layout.setWidth("100%");
		LayoutContainer vp = new LayoutContainer();
		vp.setLayout(layout);
		vp.setWidth("100%");
		
		for(int i = 0; i < 10; i++){
			vp.add(new SearchResultWidget());
		}
		
		this.add(vp);

	}


}
